<?php
/**
 * @package Waterwheel
 */
/* 
 *  Copyright 2010 Andrew Rickmann
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *  http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
require_once(dirname(__FILE__) . '/simpletest/autorun.php');

/**
 *
 * Finds the file the given class name and includes it ready for the class to be instantiated.
 * This is passed to the spl_autoload_register function to automate the process.
 *
 * @param String $classname The name of the class being instantiated.
 */
function application_autoload($classname){
	$path = APPLICATION_PATH . "/../classes" . DIRECTORY_SEPARATOR;
	$file = $path . $classname . '.php';
	if( file_exists($file) ){
		include_once($file);
	}
}

//setup the class autoloader
spl_autoload_register('application_autoload');

define('APPLICATION_PATH' , dirname(__FILE__) );

/**
 * Test of Plugin Class
 *
 * The plugin class is extended by plugins, so we are going to be calling filters
 * to make the operational test plugin use the feature and pass back the value
 *
 * @author Andrew Rickmann
 */
class TestofPlugins extends UnitTestCase {

    /**
     * D before tests
     */
    function setUp() {

    }

    /**
     * Do after tests
     */
    function tearDown() {
        
    }

    function testPluginSettings(){

	//run the plugins class once to load the plugins
	$plugins = new plugins();

	//only the operational plugin should be loaded
	//we don't need to test this though
	plugins::filter( 'settings_set' , array('TestSetting' , 'TestValue') );

	//now check that the setting has been created using the settings class
	//the plugin should be using an instance of the settings class
	//with the namespace set to plugin_{classname}.
	$settings = new settings();
	$this->assertTrue( $settings->get('TestSetting', 'plugin_operational') == 'TestValue' , 'Setting has been correctly set');

	//we are not testing the settings class, just the fact that it has been
	//correctly set up in the plugin. So no need to test retrieval et al.

	//remove all settings
	$settings->remove_settings('plugin_operational');
	
    }

    

}

?>